package com.atguigu.srb.core.controller.admin;

import com.atguigu.srb.common.result.Result;
import com.atguigu.srb.core.pojo.entity.Borrower;
import com.atguigu.srb.core.pojo.vo.BorrowerAuditVO;
import com.atguigu.srb.core.pojo.vo.BorrowerDetailVO;
import com.atguigu.srb.core.pojo.vo.BorrowerVO;
import com.atguigu.srb.core.service.BorrowerService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author lsyandwh
 * @create 2022-12-14 19:36
 */
@Api(tags = "借款人审核")
@RestController
@RequestMapping("/admin/core/borrower")
public class AdminBorrowerController {

    @Autowired
    private BorrowerService borrowerService;

    @ApiOperation("获取借款人信息列表")
    @GetMapping("/borrowerPage/{size}/{limit}")
    public Result borrowerPage(@PathVariable("size")Integer size,
                               @PathVariable("limit")Integer limit,
                               @RequestParam("keyword") String keyword){

        IPage<Borrower> page = borrowerService.pageList(size,limit,keyword);

        return Result.ok().data("page",page);
    }

    @ApiOperation("获取借款人详细信息")
    @GetMapping("/getBorrowerById/{id}")
    public Result getBorrowerById(@PathVariable Long id){

        BorrowerDetailVO borrower = borrowerService.getBorrowerById(id);

        return Result.ok().data("borrower",borrower);
    }

    @ApiOperation("借款人信息审核")
    @PostMapping("/borrowerAudit")
    public Result borrowerAudit(@RequestBody BorrowerAuditVO borrowerAuditVO){

        borrowerService.borrowerAudit(borrowerAuditVO);

        return Result.ok().message("审核完成");
    }
}
